//
//  SelfTextView.m
//  AnnCar_user
//
//  Created by LiBenCan on 17/10/26.
//  Copyright © 2017年 LiBenCan. All rights reserved.
//

#import "SelfTextView.h"
@interface SelfTextView()<UITextViewDelegate>
@end
@implementation SelfTextView

- (instancetype)initWithFrame:(CGRect)frame PlaceHodel:(NSString *)hodelStr
{
    if (self = [super initWithFrame:frame])
    {
        self.backgroundColor = [UIColor whiteColor];
        [self.layer setCornerRadius:3];
        self.layer.masksToBounds = YES;
        
        //输入框
        _placeStr = hodelStr;
        _TextV = [[UITextView alloc]initWithFrame:CGRectMake(8*screenW_6,8*screenW_6, frame.size.width-16*screenW_6,frame.size.height-16*screenW_6)];
        _TextV.backgroundColor = [UIColor whiteColor];
        _TextV.font = [UIFont systemFontOfSize:16*screenW_6];
        _TextV.text = hodelStr;
        _TextV.delegate = self;
        _TextV.textColor = TextGray;
        [self addSubview:_TextV];
    
    }
    return self;
}

-(void)textViewDidBeginEditing:(UITextView *)textView
{
    if ([textView.text isEqualToString:_placeStr]) {
        textView.text = @"";
        textView.textColor = TextBlack;
    }
}
-(void)textViewDidEndEditing:(UITextView *)textView
{
    if (textView.text.length<=0) {
        textView.text  = _placeStr;
        textView.textColor = TextGray;
    }
}

@end
